<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>easyUpload.js</title>
<link rel="stylesheet" href="easy-upload.css">
<style>
html {
	/* background: #f5f5f5; */
	background: #fff;
}
</style>
</head>
<body>
	<div id="easyContainer"></div>
	<script src="../js/jquery-2.2.3.min.js"></script>
	<script src="easyUpload.js"></script>
	<script>
    $('#easyContainer').easyUpload({
      allowFileTypes: '*.jpg;*.doc;*.pdf;*.docx',//允许上传文件类型，格式';*.doc;*.pdf;*.docx'
      allowFileSize: 100000,//允许上传文件大小(KB)
      selectText: '选择文件',//选择文件按钮文案
      multi: true,//是否允许多文件上传
      multiNum: 5,//多文件上传时允许的文件数
      showNote: true,//是否展示文件上传说明
      note: '提示：最多上传5个文件，支持格式为doc、docx、pdf、jpg',//文件上传说明
      showPreview: true,//是否显示文件预览
      url: '../uploadto',//上传文件地址
      fileName: 'file',//文件filename配置参数
      auto:true,
      formParam: {
    	    fileid:"123"//不需要验证token时可以去掉
    	  },//文件filename以外的配置参数，格式：{key1:value1,key2:value2}
      timeout: 30000,//请求超时时间
      okCode: 200,//与后端返回数据code值一致时执行成功回调，不配置默认200
      attrHtml:"",
      successFunc: function(res) {
        console.log('成功回调', res);
        var att = res.success[res.success.length-1];
        var attIndex = att.easyFileIndex;
        var attId = att.attid;
        $('#easyContainer').find(`.easy_upload_queue_item[data-index=${attIndex}]`).attr("data-attid",attId);
      },//上传成功回调函数
      errorFunc: function(res) {
        console.log('失败回调', res);
      },//上传失败回调函数
      deleteFunc: function(res,arr) {
        console.log('删除回调', res);
        console.log(arr);
        var attlist = [];
        arr.forEach(function(item){
        	attrId = $('#easyContainer').find(`.easy_upload_queue_item[data-index=${item}]`).attr("data-attid");
            attlist.push(attrId);
          });
        console.log(attlist);
      }//删除文件回调函数
    });
    
    function loadatt(){
    	var ahtml = `<li class="easy_upload_queue_item" data-index="-1" data-attid="">
    	                <div class="easy_upload_preview queue_item-section">
    	                   <i class="easy_upload_icon easyUploadIcon"></i>
    	                 </div>
    	                 <div class="easy_upload_file1 queue_item-section">
    	                   <p class="easy_upload_filename">hello.docx</p>
    	                   <p class="easy_upload_progress"><span class="easy_upload_bar" style="width: 100%;"></span></p>
    	                 </div>
    	                 <div class="easy_upload_file2 queue_item-section">
    	                   <p class="easy_upload_fiesize">0KB</p>
    	                   <p class="easy_upload_percent">100%</p>
    	                 </div>
    	                 <div class="easy_upload_status queue_item-section">
    	                   <p class="status status1" style="display: none;">可以上传</p>
    	                   <p class="status status2" style="display: none;">等待上传</p>
    	                   <p class="status status3" style="display: none;">上传中</p>
    	                   <p class="status status4" style="display: none;">上传失败</p>
    	                   <p class="status status5" style="display: block;">上传成功</p>
    	                 </div>
    	                  <div class="easy_upload_btn queue_item-section">
    	                   <p class="easy_upload_delbtn btn noselect">删除</p>
    	                  </div>
    	                  <div class="easy_upload_checkone queue_item-section">
    	                    <i class="easyUploadIcon noselect queue_check queue_check_allow_true" data-checked="no" data-up="1"></i>
    	                  </div>
    	                </li>`;
    	                
    	          return ahtml ;
    	   /*  $("#easyContainer").find("ul[class='easy_upload_queue']").html(ahtml); */
    }
  </script>
</body>
</html>